home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8752 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: nntp.onyx.net!claymoor
  2. From: Adam.Morris@octacon.co.uk (Adam Morris)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: A beginners valiant effort.
  5. Date: Mon, 26 Feb 96 19:24:58 GMT
  6. Organization: Octacon Ltd
  7. Message-ID: <4gsft7$jhc@mulgave.octacon.co.uk>
  8. References: <4g81kr$mrs@soap.news.pipex.net> <4gcvq9$8ro@nntpd2.cxo.dec.com>
  9. NNTP-Posting-Host: claymoor.onyx.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4gcvq9$8ro@nntpd2.cxo.dec.com>,
  13.    Brian Hibbert <b_hibbert@csc32.enet.dec.com> wrote:
  14. >chris.neale@ooh.conqueror.co.uk (Chris Neale) wrote:
  15. >>but the IF statement falls through - like a switch statement. Try it
  16. [deletions]
  17. >You program is not falling through the if statement to the else clause. 
  18. >The problem is with the strings that you have built and the storage space 
  19. >allocated for them.  You are using an output operator that expects a 
  20. >character pointer to point to a null terminated string and you are 
  21. >passing it a pointer to a string that is not terminated.  What happens is 
  22.  
  23. Forgive me if I am wrong, but I always thought that constant strings were null 
  24. terminated....  "test" is expanded by the compiler to 't','e','s','t','\0'
  25. Thus explicit null termination of the strings in the program is not required.
  26. the problem (as I see it) is that the array that the strings are being stored 
  27. in is not large enough to include the null terminating character, so that when
  28. the character constants are assigned to the arrays, the terminating character 
  29. is chopped off.  
  30.  
  31. Just increasing the size of the two arrays by one each should be enough to do 
  32. it.
  33.  
  34. Adam.
  35.